package week_home_work02;

import java.util.Scanner;

/**
 * @author zdl
 * @date 2024/11/22
 */
public class Demo39 {
    public static void main(String[] args) {
        //输出1到n之间所有的质数和它们的个数。
       Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个整数:");
        int num = sc.nextInt();
        int count = 0;

        for (int i = 2; i < num; i++) {
            boolean flag = true;
            for (int j = 2; j < Math.sqrt(i); j++) {
                if (i % j == 0){
                    flag = false;
                    break;
                }
            }
            if (flag){
                System.out.print(i+"\t");
                count++;
            }
        }
        System.out.println();
        System.out.println("count="+count);

    }
}
